package org.imixs.manik.webstat.jpa;

import java.util.Calendar;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Defines the location of a access log file.
 * The AccessLog is responsible for the import of acessEntries.
 * 
 * @author rsoika
 * 
 */
@javax.persistence.Entity
public class AccessLog implements java.io.Serializable {
	/**
	 * 
	 */
	public static byte ACCESS_FORMAT_COMMON = 1;
	public static byte ACCESS_FORMAT_COMBINED = 2;
	public static byte ACCESS_FORMAT_GLASSFISH31 = 3;

	private static final long serialVersionUID = 1L;

	
	private long id;
	private String name;

	
	private String logfile;
	private String path;
	private byte logformat;
	
	private Calendar lastscan;
	private long lastscanduration;
	private long totalcount;
		
	/**
	 * default constructor for JPA
	 */
	public AccessLog() {
		
		super();
		logformat=ACCESS_FORMAT_COMBINED;
	}

	

	/**
	 * returns the unique identifier for the Entity.
	 * 
	 * @return universal id
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public long getId() {
		return id;
	}

	protected void setId(long aID) {
		id = aID;
	}

	

 

	@Temporal(TemporalType.TIMESTAMP)
	public Calendar getLastscan() {
		// test if last scan if null
		if (lastscan==null) {
			// create default time
			lastscan=Calendar.getInstance();
			lastscan.set(Calendar.YEAR,1970);
			lastscan.set(Calendar.MONTH,0);
			lastscan.set(Calendar.DAY_OF_MONTH,1);
		}
		
		return lastscan;
	}



	public void setLastscan(Calendar lastentry) {
		this.lastscan = lastentry;
	}



	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	/**
	 * defines a reg expression to filter access objects
	 * @return
	 */
	public String getLogfile() {
		return logfile;
	}

	public void setLogfile(String file) {
		this.logfile = file;
	}



	public String getPath() {
		return path;
	}



	public void setPath(String path) {
		this.path = path;
	}



	public byte getLogformat() {
		return logformat;
	}



	public void setLogformat(byte logformat) {
		this.logformat = logformat;
	}



	public long getTotalcount() {
		return totalcount;
	}



	public void setTotalcount(long count) {
		this.totalcount = count;
	}



	public long getLastscanduration() {
		return lastscanduration;
	}



	public void setLastscanduration(long lastscanduration) {
		this.lastscanduration = lastscanduration;
	}

	

	
	
	
}
